package com.qf.czh.controller;

import com.qf.czh.model.RespBean;
import com.qf.czh.service.AuditService;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.apache.shiro.authz.annotation.RequiresRoles;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class AuditController {

    @Autowired
    AuditService auditService;
    RespBean respBean;

    @GetMapping("/audit/page")
    @RequiresPermissions(value = {"chuzhang:audit" , "admin:all"},logical = Logical.OR)
    public String leave(){
        String page = auditService.page();
        return page;
    }


    @PostMapping("/audit/audit")
    @ResponseBody
    public RespBean auditLeave(String opinion,String status,String id){
        Integer result = auditService.auditLeave(opinion , status, id);
        if (result == 1){
            respBean = RespBean.ok("审核成功");
        }else {
            respBean = RespBean.error("审核失败");
        }
        return respBean;
    }
}
